<template>
  <div class="common-table">
    <el-table :data="pageTableData"  :row-class-name="tableRowClassName" v-loading="config.loading" :header-cell-style="{ fontSize: '12.3px' }" :row-style="{ fontSize: '12.3px' }">
      <!-- <el-table-column label="序号" width="60" v-if="config.operate">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ (config.page - 1) * 10 + scope.$index + 1 }}</span>
        </template>
      </el-table-column> -->
      <el-table-column align="left" v-for="item in tableLabel" :key="item.prop" :label="item.label" :width="item.width ? item.width : 88">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row[item.prop] }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="80" v-if="config.operate">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pager"
      layout="prev, pager, next"
      :total="config.total"
      v-show="config.total > 0"
      :current-page.sync="config.page"
      @current-change="changePage"
      :page-sizes="[7, 14, 21, 28]"
      :page-size="7"
    ></el-pagination>
  </div>
</template>

<script>
export default {
  props: {
    tableData: Array,
    pageTableData: Array,
    tableLabel: Array,
    config: Object,
    // tableRowClassName:null,
  },
  methods: {
    handleEdit(row) {
      this.$emit('edit', row)
    },
    handleDelete(row) {
      this.$emit('del', row)
    },
    changePage(page) {
      this.$emit('changePage', page)
    },
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 0 || rowIndex === 2 || rowIndex === 4 || rowIndex === 6) {
        return 'warning-row';
      }
      return '';
    }    
  }
}
</script>

<style lang="less" scoped>
.common-table {
  height: calc(100% - 62px);
  // background-color: #fff;
  position: relative;
  .pager {
    position: absolute;
    right: 60px;
    margin-top: 15px;
  }
}
</style>
